import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome(executable_path=r"D:\python\chromedriver.exe")
driver.get("http://121.43.169.97:8848/pageA.html")
try:
    # 1. 输入用户信息
    # 用户名
    driver.find_element(By.NAME, "userA").send_keys("admin")
    # 密码
    driver.find_element(By.ID, "passwordA").send_keys("123456")
    # 电话号码
    driver.find_element(By.NAME, "telA").send_keys("18611111111")
    # 电子邮件
    driver.find_element(By.NAME, "emailA").send_keys("123@qq.com")

    # 2. 间隔3秒，修改电话号码
    time.sleep(3)
    phone_element = driver.find_element(By.NAME, "telA")
    phone_element.clear()  # 清除原有内容
    phone_element.send_keys("18600000000")  # 输入新号码

    # 3. 间隔3秒，点击'注册'按钮
    time.sleep(3)
    driver.find_element(By.XPATH, "//input[@value='注册' and @type='button']").click()

    # 4. 间隔3秒，关闭浏览器
    time.sleep(3)

finally:
    # 确保浏览器关闭
    driver.quit()
